import { Link } from "@/types/content/link";
import { useState } from "react";

export const useLinkOption = () => {
    const [isModalOpen, setIsModalOpen] = useState(false);
    const [optionType, setOptionType] = useState<'add' | 'edit'>('add')
    const [oldInfo, setOldInfo] = useState<Link.Row>();
    const close = () => {
        setIsModalOpen(false)
    };
    const openOptionDialog = (type: 'add' | 'edit', row?: Link.Row) => {
        setOptionType(type)
        setOldInfo(row)
        setIsModalOpen(true)
    }
    return {
        isModalOpen,
        setIsModalOpen,
        setOptionType,
        close,
        optionType,
        setOldInfo,
        oldInfo,
        openOptionDialog
    }
}